package cn.itcast.com.homework.day730;

import sun.awt.FwDispatcher;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;

import static java.util.Arrays.sort;

/*
2.  在一个磁盘的文件里保存26个英文小写字母（乱序），将他们读入内存中，进行排序，把排好顺序的数再重新追加写到磁盘的该文件中。

 */
public class test2 {
    public static void main(String[] args) throws IOException {
        char[] chars = new char[]{'a','s','e','t','n','f','r','i','u','j','o','d','k',
                'q','p','h','w','v','g','l','x','c','y','m','z','b'};
        FileWriter fileWriter = new FileWriter("D:\\代码\\代码\\代码\\cn\\itcast\\com\\homework\\day730\\b.txt");
        fileWriter.write(chars);
        fileWriter.close();

        FileReader reader = new FileReader("D:\\代码\\代码\\代码\\cn\\itcast\\com\\homework\\day730\\b.txt");

        char[] bytes = new char[26];
        reader.read(bytes);
        //reader.close();
        System.out.println(bytes);

        Arrays.sort(bytes);
        System.out.println(bytes);
        FileWriter writer = new FileWriter("D:\\代码\\代码\\代码\\cn\\itcast\\com\\homework\\day730\\b.txt");

        writer.write(bytes);
       writer.close();
//        FileWriter writer = new FileWriter("D:\\代码\\代码\\代码\\cn\\itcast\\com\\homework\\day730\\b.txt");
//        writer.write(bytes);
//        writer.close();
    }
}
